package commandes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class CommandeAuthentification implements Commande {
	private String next;

	public CommandeAuthentification(String next) {
		this.next = next;
	}

	@Override
	public String execute(HttpServletRequest req) throws Exception {
		
		if (req.getParameter("pseudo").equals("bastien")
				&& req.getParameter("mdp").equals("bastien")) {
			HttpSession session = req.getSession(true);
			session.setAttribute("droit", "utilisateur");
			return next;
		} else if (req.getParameter("pseudo").equals("antoine")
				&& req.getParameter("mdp").equals("antoine")) {
			HttpSession session = req.getSession(true);
			session.setAttribute("droit", "administrateur");
			return next;
		} else {
			return "index.jsp";
		}
		
	}

}
